'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async getList() {
    const { ctx } = this;
    const { pageIndex,pageSize,values } = ctx.query;
    let carSql = `SELECT * FROM shop WHERE title LIKE '%${values}%' LIMIT ${pageIndex},${pageSize}`;
    let totalSql = `SELECT * FROM shop WHERE title LIKE '%${values}%'`;
    const data=await this.app.mysql.query(carSql)
    const total=await this.app.mysql.query(totalSql)
    ctx.body={
      code:200,
      data,
      total:total.length
    }
  }
}

module.exports = HomeController;
